package com.artron.mediaartron.data.entity;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-10-31.
 */

public class ShoppingCartItemData implements Parcelable {

    /**
     * id : 8b0ea7ad7d36462aad33bc89e665bd1d
     * trolleyId : null
     * worksId : 8bf45ab196d8461fa9556f8c969c0b10
     * worksName : 框画-A
     * worksSize : 500X600
     * worksShape : 实木框
     * worksColor : 红色
     * worksTypeCode : huangkuang
     * worksThumbnailUrl : null
     * price : 399
     * quantity : 2
     * subtotal : 798
     * discount : 0
     * discountSubtotal : 0
     * couponId : null
     * skuCode : A01K02
     */



    private String title;
    private boolean isChecked;

    private String id;
    private String trolleyId;
    private String worksId;
    private String worksName;
    private String worksSize;
    private String worksShape;
    private String worksColor;
    private String worksTypeCode;
    private String worksThumbnailUrl;
    private int price;
    private int quantity;
    private int subtotal;
    private int discount;
    private int discountSubtotal;
    private String couponId;
    private String skuCode;

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        if (TextUtils.isEmpty(title)) {
            isChecked = checked;
        }
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean isTitle() {
        return !TextUtils.isEmpty(title);
    }

    public String getId() {
        return id;
    }

    public void setId(String id){
        this.id = id;
    }

    public String getTrolleyId() {
        return trolleyId;
    }

    public void setTrolleyId(String trolleyId) {
        this.trolleyId = trolleyId;
    }

    public String getWorksId() {
        return worksId;
    }

    public void setWorksId(String worksId) {
        this.worksId = worksId;
    }

    public String getWorksName() {
        return worksName;
    }

    public void setWorksName(String worksName) {
        this.worksName = worksName;
    }

    public String getWorksSize() {
        return worksSize;
    }

    public void setWorksSize(String worksSize) {
        this.worksSize = worksSize;
    }

    public String getWorksShape() {
        if ("外观尺寸".equals(worksShape)) {
            return "";
        }

        return worksShape;
    }

    public void setWorksShape(String worksShape) {
        if ("外观尺寸".equals(worksShape)) {
            worksShape = "";
        }

        this.worksShape = worksShape;
    }

    public String getWorksColor() {
        return worksColor;
    }

    public void setWorksColor(String worksColor) {
        this.worksColor = worksColor;
    }

    public String getWorksTypeCode() {
        return worksTypeCode;
    }

    public void setWorksTypeCode(String worksTypeCode) {
        this.worksTypeCode = worksTypeCode;
    }

    public String getWorksThumbnailUrl() {
        return worksThumbnailUrl;
    }

    public void setWorksThumbnailUrl(String worksThumbnailUrl) {
        this.worksThumbnailUrl = worksThumbnailUrl;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public int getSubtotal() {
        return subtotal;
    }

    public void setSubtotal(int subtotal) {
        this.subtotal = subtotal;
    }

    public int getDiscount() {
        return discount;
    }

    public void setDiscount(int discount) {
        this.discount = discount;
    }

    public int getDiscountSubtotal() {
        return discountSubtotal;
    }

    public void setDiscountSubtotal(int discountSubtotal) {
        this.discountSubtotal = discountSubtotal;
    }

    public String getCouponId() {
        return couponId;
    }

    public void setCouponId(String couponId) {
        this.couponId = couponId;
    }

    public String getSkuCode() {
        return skuCode;
    }

    public void setSkuCode(String skuCode) {
        this.skuCode = skuCode;
    }

    @Override
    public String toString() {
        return "ShoppingCartItemData{" +
                "id='" + id + '\'' +
                ", trolleyId=" + trolleyId +
                ", worksId='" + worksId + '\'' +
                ", worksName='" + worksName + '\'' +
                ", worksSize='" + worksSize + '\'' +
                ", worksShape='" + worksShape + '\'' +
                ", worksColor='" + worksColor + '\'' +
                ", worksTypeCode='" + worksTypeCode + '\'' +
                ", worksThumbnailUrl=" + worksThumbnailUrl +
                ", price=" + price +
                ", quantity=" + quantity +
                ", subtotal=" + subtotal +
                ", discount=" + discount +
                ", discountSubtotal=" + discountSubtotal +
                ", couponId=" + couponId +
                ", skuCode='" + skuCode + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.title);
        dest.writeByte(this.isChecked ? (byte) 1 : (byte) 0);
        dest.writeString(this.id);
        dest.writeString(this.trolleyId);
        dest.writeString(this.worksId);
        dest.writeString(this.worksName);
        dest.writeString(this.worksSize);
        dest.writeString(this.worksShape);
        dest.writeString(this.worksColor);
        dest.writeString(this.worksTypeCode);
        dest.writeString(this.worksThumbnailUrl);
        dest.writeInt(this.price);
        dest.writeInt(this.quantity);
        dest.writeInt(this.subtotal);
        dest.writeInt(this.discount);
        dest.writeInt(this.discountSubtotal);
        dest.writeString(this.couponId);
        dest.writeString(this.skuCode);
    }

    public ShoppingCartItemData() {
    }

    protected ShoppingCartItemData(Parcel in) {
        this.title = in.readString();
        this.isChecked = in.readByte() != 0;
        this.id = in.readString();
        this.trolleyId = in.readString();
        this.worksId = in.readString();
        this.worksName = in.readString();
        this.worksSize = in.readString();
        this.worksShape = in.readString();
        this.worksColor = in.readString();
        this.worksTypeCode = in.readString();
        this.worksThumbnailUrl = in.readString();
        this.price = in.readInt();
        this.quantity = in.readInt();
        this.subtotal = in.readInt();
        this.discount = in.readInt();
        this.discountSubtotal = in.readInt();
        this.couponId = in.readString();
        this.skuCode = in.readString();
    }

    public static final Parcelable.Creator<ShoppingCartItemData> CREATOR = new Parcelable.Creator<ShoppingCartItemData>() {
        @Override
        public ShoppingCartItemData createFromParcel(Parcel source) {
            return new ShoppingCartItemData(source);
        }

        @Override
        public ShoppingCartItemData[] newArray(int size) {
            return new ShoppingCartItemData[size];
        }
    };
}
